# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=deepin-qt5platform-plugins
pkgver=5.6.16
pkgrel=3
pkgdesc='Qt platform plugins for DDE'
arch=('loong64' 'x86_64')
url="https://github.com/linuxdeepin/qt5platform-plugins"
license=('LGPL3')
depends=('cairo' 'qt5-base' 'qt5-wayland' 'qt5-x11extras' 'dwayland' 'libx11' 'libxi'
         'libxcb' 'xcb-util-wm' 'glibc' 'gcc-libs')
makedepends=('cmake' 'ninja' 'qt5-tools' 'qt5-xcb-private-headers' 'libglvnd' 'gtest'
             'extra-cmake-modules' 'dtkcommon')
groups=('deepin')
source=("https://github.com/linuxdeepin/qt5platform-plugins/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        $pkgname-drag-crash.patch::https://github.com/linuxdeepin/qt5platform-plugins/commit/3f5c598d70e3553430e8d668091c2ea427d6d3f4.patch)
sha512sums=('1cf17decec520582fe0c5a6f9b9b83a91f6160ca0e6ae691979d0b882b8e6ca1a354eb37380e678c8227f64b685c158ef995326827b50d649d789023d87c03ee'
            '22ece1d0c414eb166a1edde12eb797a6e846028c3acd221ce8d340d603d5b114c2e45e71cb387f55dcde2c174473fae5466e42e388d0e5804e91fc166cbbc564')

prepare() {
  cd qt5platform-plugins-$pkgver
  patch -Np1 -i ../$pkgname-drag-crash.patch
  rm -r xcb/libqt5xcbqpa-dev wayland/qtwayland-dev
  sed -i '/find_package/i find_package(ECM REQUIRED 1.0.0)\nset(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})' wayland/wayland-shell/wayland-shell.cmake
  sed -i 's|qt${QT_VERSION_MAJOR}/plugins|qt/plugins|' xcb/CMakeLists.txt wayland/*/CMakeLists.txt 
}

build() {
  cd qt5platform-plugins-$pkgver
  cmake . -GNinja \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=/usr \
    -DQT_XCB_PRIVATE_HEADERS=/usr/include/qtxcb-private
  ninja
}

package() {
  cd qt5platform-plugins-$pkgver
  DESTDIR="$pkgdir" ninja install
}
